﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            TcpClient client;
            Byte[] data = new Byte[256];

            try {
                client = new TcpClient("localhost", 31173);

                NetworkStream ns = client.GetStream();

                Int32 bytes = ns.Read(data, 0, data.Length);
                String responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);

                String[] received = responseData.Split('^');
                for (int i = 0; i < received.Length; i++)
                {
                    textActivity.Text += received[i] + Environment.NewLine;
                }

                ns.Close();
                client.Close();
            }
            catch (SocketException)
            {
                textActivity.Text = "Could not connect to server!";
            }
        }

        private void textActivity_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
